home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / jcool01.zip / BASE_M_V.H < prev    next >
C/C++ Source or Header  |  1992-08-16  |  3KB  |  75 lines

  1. //
  2. // Copyright (C) 1992 General Electric Company
  3. //
  4. // Permission is granted to any individual or institution to use, copy, modify,
  5. // and distribute this software, provided that this complete copyright and
  6. // permission notice is maintained, intact, in all copies and supporting
  7. // documentation.
  8. //
  9. // General Electric Company provides this software "as is" without
  10. // express or implied warranty.
  11. //
  12. // Updated: VDN 02/21/92 -- New lite version
  13. // Updated: JAM 08/15/92 -- removed DOS specifics, stdized #includes
  14. // Updated: JAM 08/15/92 -- modernized template syntax, remove macro hacks
  15. //                          non-template classes CoolM_Vector=>CoolBase_M_Vector
  16. //
  17. // The parameterized M_Vector<Type>  class is publicly   derived from the  Base_M_Vector
  18. // class and implements one dimensional arithmetic vectors of a user specified
  19. // type.   This is accompilshed by using  the parameterized  type capability of
  20. // C++.  The only constraint placed on the type  is  that it must  overload the
  21. // following operators: +, -,  *,  and /. Thus, it will  be possible to have  a
  22. // vector of  type Complex.  The M_Vector<Type> class  is static in size, that is
  23. // once a  M_Vector<Type> of  a particular  size has been   declared, there is no
  24. // dynamic growth or resize method available.
  25. //
  26. // The Base_M_Vector class is the base class for the parameterized  M_Vector<Type> class
  27. // and implements all non-type specific functionality. The private data section
  28. // contains a slot to maintain  the length specification. There are
  29. // two constructors  for  the Base_M_Vector  class. The   first   takes  two arguments
  30. // specifying the number of elements. The second takes a reference to a
  31. // Base_M_Vector object and  reproduces its state. There  is one pulic method that
  32. // provides access to the length slot.  Finally, there are  several
  33. // private  methods  that  are called   by the   parameterized class to  handle
  34. // exceptions.
  35.  
  36. #ifndef BASE_M_VECTORH                // If no Vec class,
  37. #define BASE_M_VECTORH                // define it
  38.  
  39. #ifndef STREAMH            // If the Stream support not yet defined,
  40. #include <iostream.h>           // include the Stream class header file
  41. #define STREAMH
  42. #endif
  43.  
  44. #ifndef MISCELANEOUSH        // If we have not included this file,
  45. #include <misc.h>        // include miscelaneous useful definitions.
  46. #endif
  47.  
  48. class CoolBase_M_Vector {
  49. public:
  50.   inline int length () const;            // Return number of elements
  51.  
  52. protected:
  53.   unsigned int num_elmts;            // Number of elements
  54.   
  55.   void index_error (const char* fcn, const char* type, int) const; // Raise except.
  56.   void dimension_error (const char* fcn, const char* type, int, int) const;
  57.   void va_arg_error (const char*, int);        // Raise exception
  58.  
  59.   CoolBase_M_Vector (unsigned int elmts=1);        // Vec v (n);
  60.   CoolBase_M_Vector (const CoolBase_M_Vector&);        // Vec m1(m2);
  61.   ~CoolBase_M_Vector();                // Destructor
  62. };
  63.  
  64.  
  65. // length -- Return the number of elements in the vector
  66.  
  67. inline int CoolBase_M_Vector::length () const {
  68.   return this->num_elmts;                
  69. }
  70.  
  71.  
  72. #endif                        // End of BASE_M_VECTORH
  73.  
  74.  
  75.